<script setup>
import { ref, computed } from 'vue';

const timeRangeIndex = ref(0);
const timeRangeOptions = ["近一个月", "近三个月", "近一年"];

const signData = ref([
  {
    date: "2024/1/20",
    signTime: "2024/1/20",
    batch: "2023年春季放假",
    status: "已签到",
  },
  {
    date: "2024/1/19",
    signTime: "--",
    batch: "2023年春季放假",
    status: "未签到",
  },
  {
    date: "2024/1/18",
    signTime: "2024/1/20",
    batch: "2023年春季放假",
    status: "已签到",
  },
  {
    date: "2024/1/17",
    signTime: "2024/1/20",
    batch: "2023年春季放假",
    status: "已签到",
  },
]);

const onTimeRangeChange = (e) => {
  timeRangeIndex.value = e.detail.value;
  console.log(`选择了：${timeRangeOptions[timeRangeIndex.value]}`);
};
</script>

<template>
  <view class="sign-page">
<!--时间-->
    <view class="top-right-selector">

      <picker
          @change="onTimeRangeChange"
          :value="timeRangeIndex"
          :range="timeRangeOptions"
      >

        <view class="picker-view">
          {{ timeRangeOptions[timeRangeIndex] }}

          <image src="/static/arrow-down.png" class="arrow-icon" />

        </view>

      </picker>

    </view>
<!--签到表-->
    <view class="sign-list">

      <view
          class="sign-item"
          v-for="(item, index) in signData"
          :key="index"
      >

        <view class="item-header">

          <image src="/static/clock-icon.png" class="clock-icon" />
          <image class="icon" src="/static/image/bz8@2x.png"></image>

          <text class="sign-date">签到日期：{{ item.date }}</text>

          <text class="sign-status" :class="{ 'signed': item.status === '已签到', 'unsigned': item.status === '未签到' }">
            {{ item.status }}
          </text>

        </view>

        <view class="item-info">

          <text>签到时间：{{ item.signTime }}</text>
          <text>关联批次：{{ item.batch }}</text>

        </view>

      </view>

    </view>

  </view>
</template>

<style scoped>
.sign-page {
  padding: 16px;
  background-color: #f5f7fa;
  min-height: 100vh;
}

.top-right-selector {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
}

.picker-view {
  display: flex;
  align-items: center;
  background-color: #fff;
  padding: 6px 12px;
  border-radius: 16px;
  border: 1px solid #e5e7eb;
  font-size: 12px;
}

.arrow-icon {
  width: 10px;
  height: 10px;
  margin-left: 4px;
}

.sign-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sign-item {
  background-color: #fff;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.item-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 8px;
}

.clock-icon {
  width: 24px;
  height: 24px;
  margin-right: 8px;
}

.icon {
  width: 22px;
  height: 22px;
  margin-right: 8px;
}

.sign-date {
  width: 161px;
  height: 22px;
  font-weight: 500;
  font-size: 16px;
  color: #212121;
}

.sign-status {
  font-size: 14px;
  margin-left: auto;
}

.signed {
  color: green;
}

.unsigned {
  color: red;
}

.item-info {
  display: flex;
  flex-direction: column;
  width: 149px;
  height: 44px;
  font-weight: 400;
  font-size: 12px;
  color: #5D5E5D;
  line-height: 22px;
}
</style>